<?php
/**
 * RedCross Application
 *
 * @copyright Copyright (c) 2010, Kristian Stokke Tryggestad, Rune Vikestad, Andreas Flaten Wist, Simen Nicolai Echholt, Ole Henrik Jahren
 */


/**
 * Passive gateway
 */
class Core_Gateway_Passive extends RedCross_Gateway_GatewayAbstract
{
	
    /**
     * Constructor
     * Defines some private variables
     */
    public function __construct()
    {
        $this->_class = 'Passive';
        $this->_modelPath = 'Core_Model';
    }
    
    public function fetchPassiveMessagesForMember($memberId, $offset = null, $limit = null)
    {
    $date = new RedCross_Date();
    $dateNow = $date->get('YYYY-MM-dd HH:mm:ss');
	$query = Doctrine_Query::create()
		    ->select()
		    ->from('Core_Model_Passive p')
            ->where('p.member_id = ?', $memberId)
            ->andWhere('p.date > ?', $dateNow)
            ->orderBy('p.date ASC');
		    
	    if($offset != null && $offset !== 0){
		$query->offset($offset);
	    }
	    if($limit != null){
		$query->limit($limit);
	    }
	    
	return $query->fetchArray();
    }

}
